package cn.admin.remoting;

import org.apache.mina.common.IoFutureListener;
import org.apache.mina.common.IoSession;
import org.apache.mina.common.support.DefaultWriteFuture;

public class OverFlowWriteFuture extends DefaultWriteFuture {

    private static volatile long threshold = -1L;

    private final long totalPileup;

    public static long getThreshold() {
        return threshold;
    }

    public static void setThreshold(long value) {
        if (value <= 0L) {
            throw new IllegalArgumentException(value + "");
        } else {
            threshold = value;
        }
    }

    public static void clearThreshold() {
        threshold = -1L;
    }


    public OverFlowWriteFuture(IoSession session, IoFutureListener wfl,long pileup) {
        super(session);
        this.totalPileup = pileup;
        this.setWritten(false);
        this.addListener(wfl);
    }

    public long getTotalPileup() {
        return totalPileup;
    }
}
